package com.ttg.web.task.vipJob;

import com.ttg.common.exception.BaseException;
import com.ttg.web.service.TaskWarnNoticeService;
import com.ttg.web.service.VipBankInfoManagementService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.context.XxlJobContext;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * 更新等级和有效期
 */
@Slf4j
@Component
public class EditVipRatingHandler {


    @Autowired
    private VipBankInfoManagementService vipBankInfoManagementService;
    @Async
    @XxlJob("EditVipRatingHandler")
    public ReturnT<String> execute() {
        log.info("【JobTask editVipRating 更新等级和有效期】 start");
        boolean b = false;
        try {
            b = vipBankInfoManagementService.editVipRating();
        } catch (Exception e) {
            log.error("异常调度异常：{}",e.getMessage());
            XxlJobContext.getXxlJobContext().setHandleCode(ReturnT.FAIL_CODE);
            XxlJobContext.getXxlJobContext().setHandleMsg("执行异常，请联系管理员查询相关日志" + e.getMessage());
            throw new BaseException("异常调度异常",e.getLocalizedMessage());
        }
        log.info("【JobTask editVipRating 更新等级和有效期】 end=====>{}",b);
        return ReturnT.SUCCESS;
    }
}
